package com.atguigu.test5;

/**
 * @author 路飞
 * @date 2024/3/28 14:56
 * @description 5.	求1+2！+3！+...+20！的和
 */
public class Exer5 {
    public static void main(String[] args) {
        int count = 10;
        int sum = 0;
        for (int i = 1; i <= count; i++) {
            sum += mul(i);
        }
        System.out.println("sum = " + sum);
    }

    public static int mul(int num) {
        if (num == 1) {
            return 1;
        }
        return num * mul(num - 1);
    }
}
